<template>
	<view class="shooping_order">
		<view class="address_wrap">
			<view style="color: gray;margin-bottom: 24rpx;" @click="isShowAddressModal = true">选择地址></view>
			<view class="address_box">
				<view class="group">
					<text class="userName">{{defaultAddress.name}}</text>
					<text>{{defaultAddress.tel}}</text>
					<text class="tip" v-show="defaultAddress.isDefault">默认</text>
				</view>
				<view class="address">
					{{defaultAddress.province + defaultAddress.city + defaultAddress.county + defaultAddress.addressDetail}}
				</view>

			</view>
		</view>

		<view class="address_wrap">
			<view style="color: gray;margin-bottom: 24rpx;">订单信息</view>

			<!-- <view class="product">
				<view class="product-left">
					<u-checkbox size="40" shape="circle" v-model="item.checked"
						@change="checkIdea($event,item)"></u-checkbox>
				</view>
				<view class="product-right">
					<view class="left">
						<image :src="item.small_img" class="img"></image>
					</view>
					<view class="right">
						<view class="title-box">
							<view class="name">
								{{item.name}}
							</view>
							<view class="type">
								{{item.rule}}
							</view>
						</view>
						<view class="enname">
							{{item.enname}}
						</view>
						<view class="price">
							￥{{item.price}}
						</view>
					</view>
				</view>
				<view class="step">
					<u-number-box v-model="item.count" @change="iptMoney($event,index)"></u-number-box>
				</view>
			</view> -->
		</view>

		<!-- 地址弹出框 -->
		<u-popup v-model="isShowAddressModal" mode="bottom">
			<view class="address_popup">
					<view style="color: gray;margin-bottom: 24rpx;" @click="isShowAddressModal = true">选择地址></view>
					<view class="address_box" v-for="(item,index) in addressList" :key="index">
						<view class="group">
							<text class="userName">{{item.name}}</text>
							<text>{{item.tel}}</text>
							<text class="tip" v-show="item.isDefault">默认</text>
						</view>
						<view class="address">
							{{item.province + item.city + item.county + item.addressDetail}}
						</view>
					</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				defaultAddress: '',
				isShowAddressModal: false, // 地址popup
				addressList: [], //所有地址
			}
		},
		onLoad() {
			this.useGetDefaultAddress()
		},
		methods: {
			// 获取订单信息

			// 获取默认地址
			useGetDefaultAddress() {
				this.$request({
					url: '/findAddress',
					success: res => {
						if (res.data.code == 20000) {
							this.addressList = res.data.result
							res.data.result.find(item => {
								if (item.isDefault) {
									this.defaultAddress = item
								}
							})
						}
					}
				})
			}

		}
	}
</script>

<style lang="less" scoped>
	.shooping_order {
		background-color: #f7f7f7;
		padding: 24rpx;

		// 地址
		.address_wrap {
			background-color: #fff;
			padding: 24rpx;
			margin-bottom: 24rpx;

			.group {
				display: flex;
				justify-content: space-between;

				.userName {
					color: #103fb9;
					font-weight: bold;
				}

				.tip {
					background-color: #103fb9;
					display: inline-block;
					padding: 2rpx 10rpx;
					border-radius: 30%;
					color: #fff;
				}
			}

			.address {
				color: gray;
			}
		}

		// 选择地址模态框
		.address_popup {
			padding: 24rpx;
		}
	}
</style>
